#encoding = utf-8
#此程序用于消防指示牌产品使用取模软件后的数据，再进行一次变换才可用到程序当中，变换后的取模值保存在当前工程目录文件夹
#取模配置：阴码，逆向，C51格式，行列式，每行显示8点阵
array_source = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x20,0xFF,0x11,
0x10,0xFF,0x08,0x04,0x9C,0x60,0x98,0x07,
0x00,0x00,0x00,0x00,0x00,0x78,0x3C,0x1E,
0x0F,0xFF,0xFF,0xFF,0x0F,0x1E,0x3C,0x78,
0x00,0x00,0x00,0x00,0x00,0x00,0x87,0x44,
0x30,0xC7,0x01,0x01,0xE0,0x00,0x01,0xF2,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x05,0x08,0x10,
0x60,0x1F,0x02,0x02,0x3F,0x02,0x02,0x7F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x22,0x22,0x22,
0xFE,0x20,0x20,0x21,0x21,0x21,0xFF,0x00,
0xF0,0xF0,0x70,0x70,0x70,0x70,0x70,0x70,
0x70,0xF0,0xF0,0x70,0x70,0x70,0x70,0x70,
0x70,0xF0,0xF0,0x00,0x00,0xE2,0x22,0x22,
0x23,0x20,0x20,0x24,0x24,0xE4,0x27,0x04,
0xFF,0xFF,0x00,0x1C,0x1C,0x1C,0xF8,0xFC,
0xE6,0xE7,0xE3,0xE0,0x60,0x30,0x18,0x0C,
0x00,0x0C,0x19,0x00,0x00,0x3F,0x20,0x20,
0xA0,0xA0,0xA0,0xA0,0xA0,0xBF,0xA0,0x00,
0xFF,0xFF,0x80,0x80,0x80,0x80,0x83,0x87,
0x8C,0x98,0xB0,0xE0,0x83,0x83,0xBC,0xBC,
0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x8B,0x88,0x50,0x23,0x50,0x88,0x8B,0x00,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,
0xFA,0x22,0x22,0x22,0x22,0x22,0x22,0x00
]
#第一行和第二行第一个字取模
array1_A = array_source[0:32]
array1_B = array_source[32:64]
array1_new = []
i = 0
for num in array1_A:
    array1_new.append(num)
    array1_new.append(array1_B[i])
    i+=1

#第一行和第二行第2个字取模
array2_A = array_source[64:96]
array2_B = array_source[96:128]
array2_new = []
i = 0
for num in array2_A:
    array2_new.append(num)
    array2_new.append(array2_B[i])
    i+=1

#第一行和第二行第3个字取模
array3_A = array_source[128:160]
array3_B = array_source[160:192]
array3_new = []
i = 0
for num in array3_A:
    array3_new.append(num)
    array3_new.append(array3_B[i])
    i+=1

#第一行和第二行第4个字取模
array4_A = array_source[192:224]
array4_B = array_source[224:256]
array4_new = []
i = 0
for num in array4_A:
    array4_new.append(num)
    array4_new.append(array4_B[i])
    i+=1
#将4个列表放入一个列表中，以便循环
array_list = [array1_new,array2_new,array3_new,array4_new]
#获取文件名
file_name = input("请输入要保存的文件名：")
file_name += "取模变换.txt"
file_open = open(file_name,"w+")
i = 0
for array in array_list:
    i+=1
    for num in array[0:32]:
        if num > 0x0f:
            file_open.write("0x%x"%num + ',')
        else:
            file_open.write("0x0%x" % num + ',')
    file_open.write("  /*第一行第%d个字*/"%i + "\n\n")
file_open.write("*"*150+"\n\n")
i = 0
for array in array_list:
    i += 1
    for num in array[32:64]:
        if num > 0x0f:
            file_open.write("0x%x"%num + ',')
        else:
            file_open.write("0x0%x" % num + ',')
    file_open.write("  /*第二行第%d个字*/" % i + "\n\n")
